//
//  ViewController.swift
//  ResponderChain
//
//  Created by lirenqiang on 16/7/21.
//  Copyright © 2016年 lirenqiang. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    
    func clickButton() {
        
        print("我被点击啦")
        
    }
    
    

    override func viewDidLoad() {
        super.viewDidLoad()
        let button = UIButton(frame: CGRect(x: 50, y: 50, width: 100, height: 100))
        button.backgroundColor = UIColor.blueColor()
        view.addSubview(button)
        
        setupButton()
        
        button.addTarget(self, action: "clickButton", forControlEvents: UIControlEvents.TouchUpInside)
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

extension ViewController {
    
    func setupButton() {
        
        let button1 = UIButton(frame: CGRect(x: 200, y: 200, width: 100, height: 100))
        button1.backgroundColor = UIColor.redColor()
        view.addSubview(button1)
        
//        button1.addTarget(self, action: #selector(clickButton), forControlEvents: UIControlEvents.TouchUpInside)
    }
    
}

